<!-- 分享设置 -->

<template>
  <el-form
    ref="formRef"
    :model="form.data"
    :disabled="form.status==='r'||form.submitting"
    :label-width="form.show&&isActive?'auto':undefined"
    class="commodity-form-module"
  >
    <!-- 规则：必选， 1. 文本类型 2. 最大长度45字符 -->
    <el-form-item
      label="分享标题"
      prop="headline"
      verify
    >
      <el-input
        class="show-word-limit"
        v-model.trim="form.data.headline"
        show-word-limit
        maxlength="45"
        placeholder="请填写分享标题"
      ></el-input>
    </el-form-item>
    <!-- 规则：必选， 1. 文本类型 2. 最大长度45字符 -->
    <el-form-item
      label="分享说明"
      prop="simpleDescription"
      verify
    >
      <el-input
        class="show-word-limit"
        v-model.trim="form.data.simpleDescription"
        show-word-limit
        maxlength="45"
        placeholder="请填写分享说明"
      ></el-input>
    </el-form-item>

    <!-- 分享奖励金 -->
    <div class="integrated">
      <!-- 规则：必选，存在三种形式 -->
      <!-- 无分享, 用户不需要输入，清除calculationRewards、distributionRewards、rewardsAmount字段 -->
      <!-- 百分比分享, 用户需要输入 清除rewardsAmount字段 -->
      <!-- 具体奖励金, 用户需要输入 清除distributionRewards字段 -->
      <el-form-item
        label="分享奖励金"
        prop="exitDistr"
        verify
      >
        <el-select
          style="width: 100%"
          v-model="form.data.exitDistr"
          placeholder="请选择是否分享奖励金"
        >
          <el-option
            v-for="item in $enum.ENUM_COMMODITY_SHARE_REWARDS_SWITCH_TYPE"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        v-if="showShareRewardsSwitchType"
        label="分享奖励金规则"
        prop="calculationRewards"
        verify
      >
        <el-select
          style="width: 100%"
          v-model="form.data.calculationRewards"
          placeholder="请选择分享奖励金规则"
        >
          <el-option
            v-for="item in $enum.ENUM_COMMODITY_SHARE_REWARDS_RULER_TYPE"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <!-- 规则： 必选，百分比奖励金 1. 允许输入number，限制小数时精度保留两位 2. 大小范围0% ~ 30% -->
      <el-form-item
        v-if="
          showShareRewardsSwitchType &&
              showShareRewardsType(
                  '按百分制计算奖励金'
              )
      "
        label="百分制奖励金"
        prop="distributionRewards"
        verify
      >
        <el-input
          v-model="form.data.distributionRewards"
          v-min="0"
          v-max="30"
          v-precision="2"
          placeholder="请填写按百分制分享奖励金，范围0.01~30"
        >
          <template slot="append">%</template>
        </el-input>
      </el-form-item>
      <!-- 规则： 必选，奖励金额 1. 允许输入number，限制小数时精度保留两位 2. 大小范围0 ~ 100000 -->
      <el-form-item
        v-if="
          showShareRewardsSwitchType &&
              showShareRewardsType('按金额计算')
      "
        label="奖励金额"
        prop="__rewardsAmount"
        :verify="{ type: 'number', gte: 0, lte: 100000 }"
      >
        <PriceInput
          v-model.trim="form.data.rewardsAmount"
          :yuan.sync="form.data.__rewardsAmount"
        />
      </el-form-item>
    </div>

    <!-- 规则：必选， 1. 限制1张图片 2. 比例1: 1 -->
    <el-form-item
      label="分享封面"
      prop="coverUrl"
      verify
    >
      <Imgpond
        v-model="form.data.coverUrl"
        :count="1"
        aspectRatio="1/1"
      />
    </el-form-item>
  </el-form>
</template>

<script>
import mixin from './mixin'

export default {
  name: 'ShareSettings',
  mixins: [mixin],
  data () {
    return {}
  },
  methods: {}
}
</script>

<style lang="scss" scoped>

</style>
